package com.fifth.commodity.controller.api;

import com.fifth.common.pojo.dto.CommonResult;
import com.fifth.common.pojo.entity.Unit;
import com.fifth.commodity.service.UnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/unit")
public class ApiUnitConteroller {
    @Autowired
    private UnitService unitService;
    /*
    * 查询所有
    * */
    @PostMapping("/unitselectall")
    public CommonResult UnitSelectAll(@RequestBody Unit unit){
        CommonResult unitnall = unitService.UnitSelectAll(unit);
        return new CommonResult(2000,"查询成功",unitnall);
    }
    /*
     * 添加
     * */
    @PostMapping("unitinsert")
    public CommonResult UnittInsert(@RequestBody Unit unit){
        CommonResult commonResult = unitService.UnitInsert(unit);
        return new CommonResult(2000,"添加成功",commonResult);
    }
    /*
     * 修改
     * */
    @PostMapping("sortupdate")
    CommonResult SortUpdate(@RequestBody Unit unit){
        CommonResult commonResult = unitService.UnitUpdate(unit);
        return new CommonResult(2000,"修改成功",commonResult);
    }

    /*
     * 删除
     * */
    @GetMapping("unitdelete/{id}")
    public CommonResult UnitDelete(@PathVariable String id){
        CommonResult commonResult = unitService.UnitDelete(id);
        return new CommonResult(2000,"删除成功",commonResult);
    }
}
